﻿<%@ Page Language="C#" AutoEventWireup="true" %>

<%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls"
    TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    protected void submit_Click(object sender, EventArgs e) {
        userIdHiddenField.Value = loginAs.Text;
    }    
</script>

<script type="text/javascript" language="javascript">
function onSilverlightError(sender, errorArgs)
{
    // The error message to display.
    var errorMsg = "Silverlight Error: \n\n";
    
    // Error information common to all errors.
    errorMsg += "Error Type:    " + errorArgs.errorType + "\n";
    errorMsg += "Error Message: " + errorArgs.errorMessage + "\n";
    errorMsg += "Error Code:    " + errorArgs.errorCode + "\n";
    
    // Determine the type of error and add specific error information.
    switch(errorArgs.errorType)
    {
        case "RuntimeError":
            // Display properties specific to RuntimeErrorEventArgs.
            if (errorArgs.lineNumber != 0)
            {
                errorMsg += "Line: " + errorArgs.lineNumber + "\n";
                errorMsg += "Position: " +  errorArgs.charPosition + "\n";
            }
            errorMsg += "MethodName: " + errorArgs.methodName + "\n";
            break;
        case "ParserError":
            // Display properties specific to ParserErrorEventArgs.
            errorMsg += "Xaml File:      " + errorArgs.xamlFile      + "\n";
            errorMsg += "Xml Element:    " + errorArgs.xmlElement    + "\n";
            errorMsg += "Xml Attribute:  " + errorArgs.xmlAttribute  + "\n";
            errorMsg += "Line:           " + errorArgs.lineNumber    + "\n";
            errorMsg += "Position:       " + errorArgs.charPosition  + "\n";
            break;
        default:
            break;
    }
    
    errorMsg = errorMsg.replace('\n', '\n<br />');
    var silverlightDiv = $get("silverlightDiv");
    silverlightDiv.innerHTML = errorMsg;
}

</script>

<html xmlns="http://www.w3.org/1999/xhtml" style="height: 100%;">
<head runat="server">
    <title>Test Page For GNUGo.Net.Silverlight</title>
</head>
<body style="height: 100%; margin: 0;">
    <form id="form1" runat="server" style="height: 100%;">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    Log In As:
    <asp:TextBox runat="server" ID="loginAs" Text="lprichar" />
    <asp:Button ID="submit" runat="server" Text="Change Logon Id" OnClick="submit_Click" />
    <br />
    <asp:HiddenField runat="server" ID="sessionKeyHiddenField" Value="sessionId"></asp:HiddenField>
    <asp:HiddenField runat="server" ID="userIdHiddenField" Value="lprichar"></asp:HiddenField>
    <div id="silverlightDiv" style="height: 100%;">
        <object data="data:application/x-silverlight," type="application/x-silverlight-2-b2"
            width="100%" height="100%">
            <param name="source" value="ClientBin/GNUGo.Net.Silverlight.xap" />
            <param name="onerror" value="onSilverlightError" />
            <param name="background" value="white" />
            <a href="http://go.microsoft.com/fwlink/?LinkID=115261" style="text-decoration: none;">
                <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight"
                    style="border-style: none" />
            </a>
        </object>
        <%--<asp:Silverlight ID="Xaml1" runat="server" MinimumVersion="2.0.30523" OnPluginError="onPluginError" Source="~/ClientBin/GNUGo.Net.Silverlight.xap" Version="2.0" Width="100%" Height="100%" />--%>
    </div>
    </form>
</body>
</html>
